package net.anzhuo.service.impl;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsGaoGuanMapper;
import net.anzhuo.entity.GsGaoGuan;
import net.anzhuo.service.GsGaoGuanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GsGaoGuanServiceImpl implements GsGaoGuanService {

	@Autowired
	private GsGaoGuanMapper gsGaoGuanMapper;

	@Override
	public PaginationVO<GsGaoGuan> getListWithPage(GsGaoGuan gsGaoGuan) {
		PaginationVO<GsGaoGuan> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsGaoGuanMapper.getListWithPage(gsGaoGuan));
		paginationVO.setTotalCount(gsGaoGuanMapper.getCount(gsGaoGuan));
		paginationVO.setTotalPage((gsGaoGuanMapper.getCount(gsGaoGuan) + gsGaoGuan.getPageSize() -1)  / gsGaoGuan.getPageSize());
		paginationVO.setPageNo(gsGaoGuan.getPageNo());
		return paginationVO;
	}

	@Override
	public GsGaoGuan getById(Long id) {
		return gsGaoGuanMapper.getById(id);
	}



	@Override
	public List<GsGaoGuan> getList(GsGaoGuan gsGaoGuan) {
		return gsGaoGuanMapper.getList(gsGaoGuan);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsGaoGuan gsGaoGuan) {
		gsGaoGuanMapper.update(gsGaoGuan);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsGaoGuan gsGaoGuan) {
		gsGaoGuanMapper.save(gsGaoGuan);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsGaoGuan gsGaoGuan) {
		gsGaoGuanMapper.delete(gsGaoGuan);
	}

	@Override
	public List<GsGaoGuan> getByMd5(String md5) {
		return gsGaoGuanMapper.getByMd5(md5);
	}
}
